package com.lanchetech.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * 聊天用户表
 */
@ApiModel(value = "com-lanchetech-entity-MsgUser")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class MsgUser implements Serializable, UserDetails {
    @ApiModelProperty(value = "")
    private Long id;

    /**
     * 账号
     */
    @ApiModelProperty(value = "账号")
    private String username;

    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    private String password;

    /**
     * 服务者名称
     */
    @ApiModelProperty(value = "服务者名称")
    private String serviceName;

    /**
     * 最近一次修改密码时间
     */
    @ApiModelProperty(value = "最近一次修改密码时间")
    private Date lastPasswordResetDate;

    /**
     * 用户状态 0 不在服务中 1 服务中
     */
    @ApiModelProperty(value = "用户状态 0 不在服务中 1 服务中")
    private Byte status;

    /**
     * 关联用户id、商家id、平台id、消息id
     */
    @ApiModelProperty(value = "关联用户id、商家id、平台id、消息id")
    private Long relateId;

    /**
     * 昵称
     */
    @ApiModelProperty(value = "昵称")
    private String nickname;

    /**
     * 头像
     */
    @ApiModelProperty(value = "头像")
    private String avatar;

    /**
     * 用户角色 0 普通用户 1 商家客服 2 平台客服 3 平台消息
     */
    @ApiModelProperty(value = "用户角色 0 普通用户 1 商家客服 2 平台客服 3 平台消息")
    private Byte role;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    private Long tenantId;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    private Date createdAt;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    private Date updatedAt;

    /**
     * 删除 0 未删除 1 已删除
     */
    @ApiModelProperty(value = "删除 0 未删除 1 已删除")
    private Byte deleted;

    private static final long serialVersionUID = 1L;

    public static MsgUserBuilder builder() {
        return new MsgUserBuilder();
    }


    public Date getLastPasswordResetDate() {
        return lastPasswordResetDate;
    }

    public void setLastPasswordResetDate(Date lastPasswordResetDate) {
        this.lastPasswordResetDate = lastPasswordResetDate;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() { //2
        List<GrantedAuthority> auths = new ArrayList<GrantedAuthority>();
        return auths;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}